/*-----------------------------------------------------------------------------
 * @file   utils_str.h
 * @brief  utils for string operation
 * @author WLH<wanglehui8357@163.com> Copyright (C) 2021~2099.
 ----------------------------------------------------------------------------*/
#ifndef UTILS_STR_H
#define UTILS_STR_H

#include "globaldef.h"

BEGIN_DECLS

/*-----------------------------------------------------------------------------
 * public functions
 ----------------------------------------------------------------------------*/
/**
 * @brief      0 : str1 == str2
 *             1 : str1 >  str2
 *            -1 : str1 <  str2
 */
int str_util_cmp(const char* str1, const char* str2, const bool ignore_case);
/**
 * @brief  return true if str1 is equal to str2 by specifying length
 */
bool str_util_is_equal(const char* str1, const char* str2, const size_t len);
/**
 * @brief      get the index of chart in string
 *
 * @param[in]  pstr  The point to string
 * @param[in]  c     The char to be found
 * @param[in]  cnt   The count of char in string
 *
 * @return     the index of chart in string
 */
int str_util_index(const char* pstr, const char c, const size_t cnt);

/**
 * @brief      check string is digital or not
 *
 * @param[in]  pstr  The point to string
 * @param[in]  cnt   The count of char in string
 *
 * @return     true if is digital string , otherwise return false
 */
bool str_util_is_digital(const char* pstr, const size_t cnt);

/**
 * @brief      Calc hash data of string
 *
 * @param[in]  pstr  The point to string
 * @param[in]  cnt   The count of char in string
 *
 * @return     true if is digital string , otherwise return false
 */
U32 str_util_hash(const char* pstr, const size_t cnt);
/**
 * @brief      Get the length of string, less than 255
 * @param[in]  pstr  The point to string
 *
 * @return     the length of string;
 */
U8  str_util_len(const char* pstr);

END_DECLS

#endif //~UTILS_STR_H
